<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>18、表单属性指令-v-model-checkbox复选框.html</title>
</head>
<body>

<div id="app">
    <p v-for="(item,index) in hobbysArr" :key="item.id"><input type="checkbox" v-model="hobbys" v-bind:value="item" :id="'hobbys'+index"><label :for="'hobbys'+index">{{item.name}}</label></p>
    <p>你选择的元素是：{{hobbys}}</p>
</div>

<script src="js/vue.global.js"></script>
<script>
    var vm = Vue.createApp({
        created(){
        },
        data() {
            return {
                hobbys:[{id:2,name:"篮球2"}],
                hobbysArr:[
                    {id:1,name:"篮球1"},
                    {id:2,name:"篮球2"},
                    {id:3,name:"篮球3"}
                ]
            }
        },
        methods:{
            loginbtn(){
                var intro = this.intro;
                alert("你获取的内容是:" + intro)
            }
        }

    }).mount("#app");
</script>

</body>
</html>